package com.yjhh.scala

/**
  *
  *
  * Created by hlantian on 2017/12/4.
  */
object HelloHierachyAndTriait {

  def main(args: Array[String]): Unit = {

    val succ = (x: Int) => x + 1

    /*
    * 其实scala的函数编程实质背后是类，实现了Function接口，接口中有个callback，callback中有个
    * apply方法，传值时调用了apply方法
    *
    * Function[Int, Int]中第一个Int是传入类型，第二个Int是返回类型
    */
    val anonfun1 = new Function[Int, Int] {
      override def apply(x: Int) = {
        x + 1
      }
    }

    assert(succ(0) == anonfun1(0))
  }
}



